﻿@Html.Label("Choose Tag's Parent") <br/>
<div class="indented-groupbox">
    @Html.Label("Parent Id")
    <input type="text" name="parentId" value="" id="varParentId"/> &nbsp;
    <input type="button" value="Select" id="btnSelectParent"/>
    <div id="varSelectedParent"></div>
</div>

<script type="text/javascript">
    $(document).ready(function() {
        $("#btnSelectParent").click(function() {
            var action = "@Url.Action("GetTagById", "Tag")";
            var parentId = $("#varParentId").val();
            if (parentId > 0) {
                $.getJSON(action, { id: parentId }, function(data) {
                    $("#varSelectedParent").text($("#varParentId").val() + " [" + data.Name + "]");
                });
            } else {
                $("#varSelectedParent").text("");
            }
        });
    });
</script>
